package com.example.hello_world.BroadcastReceiver;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.hello_world.R;

public class BroadcastB extends AppCompatActivity {//静态广播

    private Button sendB;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_broadcast_b);

        sendB=findViewById(R.id.sendB);
        sendB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent=new Intent();
                intent.setComponent(new ComponentName(BroadcastB.this,MyStaticReceiver.class));
                sendBroadcast(intent);
            }
        });
    }
}